<template>
  <div
    style="height: 600px; overflow: auto; margin-bottom: 20px"
  >
    <el-form
      ref="form"
      label-position="left"
      :model="form"
      label-width="140px"
    >
      <!-- 1 -->
      <el-row>
        <!-- 发射地面站 -->
        <el-col :span="12">
          <el-form-item label="发射地面站" prop="sendStationID">
            <el-select
              ref="sendStationID"
              v-model="task.sendStationID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择发射地面站"
              style="width: 80%"
              @click.native="LoadStationList"
            >
              <el-option
                v-for="item in sendStationList"
                :key="item.ID"
                :label="item.name"
                :value="item.ID"
              />
            </el-select>
          </el-form-item>
        </el-col>

        <!-- 接收地面站 -->
        <el-col :span="12">
          <el-form-item label="接收地面站" prop="receiveStationID">
            <el-select
              ref="receiveStationID"
              v-model="task.receiveStationID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择接收地面站"
              style="width: 80%"
              @click.native="LoadStationList"
            >
              <el-option
                v-for="item in receiveStationList"
                :key="item.ID"
                :label="item.name"
                :value="item.ID"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 2 -->
      <el-row>
        <!-- 发射链路 -->
        <el-col :span="12">
          <el-form-item label="发射链路" prop="sendChainID">
            <el-select
              ref="sendChainID"
              v-model="task.sendChainID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择发射链路"
              style="width: 80%"
              @click.native="LoadSendChainList"
            >
              <el-option
                v-for="item in sendChainList"
                :key="item.ID"
                :label="item.name"
                :value="item.ID"
              />
            </el-select>
          </el-form-item>

          <!-- 发射链路图 -->
          <div>
            <div>
              <img src="@/assets/yiq/图片1_1png.png" alt="" style="width: 70%" />

              <!-- Cp -->
              <img
                src="@/assets/yiq/图片_文学touming.png"
                alt=""
                style="width: 1.5%; top: 41%; left: 16%; position: absolute;"
                @click="LianVisible('Cp')"
              />

              <!-- Cn -->
              <img
                src="@/assets/yiq/图片_文学touming.png"
                alt=""
                style="width: 1.5%; top: 57%; left: 17%; position: absolute;"
                @click="LianVisible('Cn')"
              />

              <!-- Lt -->
              <img
                src="@/assets/yiq/图片_文学touming.png"
                alt=""
                style="width: 1.5%; top: 71%; left: 22%; position: absolute;"
                @click="LianVisible('Lt')"
              />

              <!-- LpTX -->
              <img
                src="@/assets/yiq/图片_文学touming.png"
                alt=""
                style="width: 1.5%; top: 62%; left: 13.4%; position: absolute;"
                @click="LianVisible('LpTX')"
              />

              <!-- 接收信号源 -->
              <img
                src="@/assets/yiq/图片1透明.png"
                alt=""
                style="width: 5%; top: 43%; left: 31%; position: absolute;"
                @click="parentClick()"
              />

              <!-- 接收频谱仪 -->
              <img
                src="@/assets/yiq/图片1透明.png"
                alt=""
                style="width: 5%; top: 72%; left: 31%; position: absolute;"
                @click="parentClick()"
              />

              <!-- 接收功率计 -->
              <img
                src="@/assets/yiq/图片1透明.png"
                alt=""
                style="width: 5%; top: 87%; left: 13%; position: absolute;"
                @click="parentClick()"
              />
            </div>
          </div>
        </el-col>

        <!-- 接收链路 -->
        <el-col :span="12">
          <el-form-item label="接收链路" prop="receiveChainID">
            <el-select
              ref="receiveChainID"
              v-model="task.receiveChainID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择接收链路"
              style="width: 80%"
              @click.native="LoadReceiveChainList"
            >
              <el-option
                v-for="item in receiveChainList"
                :key="item.ID"
                :label="item.name"
                :value="item.ID"
              />
            </el-select>
          </el-form-item>

          <!-- 接收链路图 -->
          <div>
            <img src="@/assets/yiq/图片2.png" alt="" style="width: 80%" />

            <!-- Cr -->
            <img
              src="@/assets/yiq/图片_文学touming.png"
              alt=""
              style="width: 1.5%; top: 45%; left: 60%; position: absolute;"
              @click="LianVisible('Cr')"
            />

            <!-- Lt -->
            <img
              src="@/assets/yiq/图片_文学touming.png"
              alt=""
              style="width: 1.5%; top: 59%; left: 60%; position: absolute;"
              @click="LianVisible('Lt')"
            />

            <!-- C1 -->
            <img
              src="@/assets/yiq/图片_文学touming.png"
              alt=""
              style="width: 1.5%; top: 72%; left: 58%; position: absolute;"
              @click="LianVisible('C1')"
            />

            <!-- B -->
            <img
              src="@/assets/yiq/图片_文学touming.png"
              alt=""
              style="width: 1.5%; top: 78%; left: 64.4%; position: absolute;"
              @click="LianVisible('B')"
            />

            <!-- C -->
            <img
              src="@/assets/yiq/图片_文学touming.png"
              alt=""
              style="width: 1.5%; top: 89%; left: 83%; position: absolute;"
              @click="LianVisible('C')"
            />

            <!-- A -->
            <img
              src="@/assets/yiq/图片_文学touming.png"
              alt=""
              style="width: 1.5%; top: 45%; left: 62%; position: absolute;"
              @click="LianVisible('A')"
            />

            <!-- Li -->
            <img
              src="@/assets/yiq/图片_文学touming.png"
              alt=""
              style="width: 1.5%; top: 67%; left: 62%; position: absolute;"
              @click="LianVisible('Li')"
            />

            <!-- 接收信号源 -->
            <img
              src="@/assets/yiq/图片1透明.png"
              alt=""
              style="width: 5%; top: 80%; left: 85%; position: absolute"
              @click="parentClick()"
            />

            <!-- 接收频谱仪 -->
            <img
              src="@/assets/yiq/图片1透明.png"
              alt=""
              style="width: 5%; top: 48%; left: 85%; position: absolute"
              @click="parentClick()"
            />

            <!-- 接收功率计 -->
            <img
              src="@/assets/yiq/图片1透明.png"
              alt=""
              style="width: 5%; top: 68%; left: 73%; position: absolute"
              @click="parentClick()"
            />
          </div>
        </el-col>
      </el-row>

      <!-- 3 -->
      <el-row>
        <!-- 回传链路 -->
        <el-col :span="12">
          <el-form-item label="回传链路" prop="sendReceiveChainID">
            <el-select
              ref="sendReceiveChainID"
              v-model="task.sendReceiveChainID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择回传链路"
              style="width: 80%"
              @click.native="LoadSendReceiveChainList"
            >
              <el-option
                v-for="item in sendReceiveChainList"
                :key="item.ID"
                :label="item.name"
                :value="item.ID"
              />
            </el-select>
          </el-form-item>
        </el-col>

        <!-- 注入链路 ===== bug 无法选中-->
        <el-col :span="12">
          <el-form-item label="注入链路" prop="receiveSendChainID">
            <el-select
              ref="receiveSendChainID"
              v-model="task.receiveSendChainID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择注入链路"
              style="width: 80%"
              @click.native="LoadReceiveSendChainList"
            >
              <el-option
                v-for="item in receiveSendChainList"
                :key="item.ID"
                :label="item.name"
                :value="item.ID"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 4 -->
      <el-row>
        <!-- 上行波段 -->
        <el-col :span="12">
          <el-form-item label="上行波段" prop="chainUpBandType">
            <el-select
              v-model="task.chainUpBandType"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择上行波段"
              style="width: 80%"
            >
              <el-option
                v-for="item in bandTypes"
                :key="item.key"
                :label="item.simple_name"
                :value="item.key"
              />
            </el-select>
          </el-form-item>
        </el-col>

        <!-- 下行波段 -->
        <el-col :span="12">
          <el-form-item label="下行波段" prop="chainDownBandType">
            <el-select
              v-model="task.chainDownBandType"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择下行波段"
              style="width: 80%"
            >
              <el-option
                v-for="item in bandTypes"
                :key="item.key"
                :label="item.simple_name"
                :value="item.key"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 5 -->
      <el-row>
        <!-- 上行空间损耗 -->
        <el-col :span="12">
          <el-form-item label="上行空间损耗" prop="chainUpSkyLoss">
            <el-input v-model="task.chainUpSkyLoss" style="width: 80%">
              <el-button
                slot="append"
                icon=""
                @click="countSentence(1, chainUpSkyLossSentence)"
              >计算
              </el-button
              >
            </el-input>
          </el-form-item>
        </el-col>

        <!-- 下行空间损耗 -->
        <el-col :span="12">
          <el-form-item label="下行空间损耗" prop="chainDownSkyLoss">
            <el-input v-model="task.chainDownSkyLoss" style="width: 80%">
              <el-button
                slot="append"
                icon=""
                @click="countSentence(2, chainDownSkyLossSentence)"
              >计算
              </el-button
              >
            </el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 6 -->
      <el-row>
        <!-- 上行极化 -->
        <el-col :span="12">
          <el-form-item label="上行极化" prop="chainUpPolarisationType">
            <el-select
              v-model="task.chainUpPolarisationType"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择上行极化"
              style="width: 80%"
            >
              <el-option
                v-for="item in polarisationTypes"
                :key="item.key"
                :label="item.simple_name"
                :value="item.key"
              />
            </el-select>
          </el-form-item>
        </el-col>

        <!-- 下行极化 -->
        <el-col :span="12">
          <el-form-item
            label="下行极化"
            prop="chainDownPolarisationType"
          >
            <el-select
              v-model="task.chainDownPolarisationType"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择下行极化"
              style="width: 80%"
            >
              <el-option
                v-for="item in polarisationTypes"
                :key="item.key"
                :label="item.simple_name"
                :value="item.key"
              />
            </el-select>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 7 -->
      <el-row>
        <!-- 上行大气损耗修正值 -->
        <el-col :span="12">
          <el-form-item
            label="上行大气损耗修正值"
            prop="chainUpAtmosphereLoss"
          >
            <el-input
              v-model="task.chainUpAtmosphereLoss"
              style="width: 80%"
            />
          </el-form-item>
        </el-col>

        <!-- 下行大气损耗修正值 -->
        <el-col :span="12">
          <el-form-item
            label="下行大气损耗修正值"
            prop="chainDowmAtmosphereLoss"
          >
            <el-input
              v-model="task.chainDowmAtmosphereLoss"
              style="width: 80%"
            />
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 8 -->
      <el-row>
        <!-- 发射信号源1 -->
        <el-col :span="12">
          <el-form-item
            label="发射信号源1"
            prop="transmitSignalInstrumentID"
          >
            <el-select
              ref="transmitSignalInstrument1ID"
              v-model="task.transmitSignalInstrument1ID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择发射信号源1"
              style="width: 80%"
              @click.native="LoadSendChainInstrumentList"
            >
              <el-option
                v-for="item in recetransmitSignalInstrumentList"
                :key="item.ID"
                :label="item.name"
                :value="item.instrumentID"
              />
            </el-select>
            <el-button
              v-if="task.transmitSignalInstrument1ID"
              icon="el-icon-search"
              circle
              @click="parentClick(task.transmitSignalInstrument1ID)"
            ></el-button>
          </el-form-item>
        </el-col>

        <!-- 注入信号源 -->
        <el-col :span="12">
          <el-form-item
            label="注入信号源"
            prop="injectSignalInstrumentID"
          >
            <el-select
              ref="injectSignalInstrumentID"
              v-model="task.injectSignalInstrumentID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择注入信号源"
              style="width: 80%"
              @click.native="LoadReceiveSendChainInstrumentList"
            >
              <el-option
                v-for="item in injectSignalInstrumentList"
                :key="item.ID"
                :label="item.name"
                :value="item.instrumentID"
              />
            </el-select>
            <el-button
              v-if="task.injectSignalInstrumentID"
              icon="el-icon-search"
              circle
              @click="parentClick(task.injectSignalInstrumentID)"
            ></el-button>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 9 -->
      <el-row>
        <!-- 发射信号源2 -->
        <el-col :span="12">
          <el-form-item
            label="发射信号源2"
            prop="transmitSignalInstrument2ID"
          >
            <el-select
              v-model="task.transmitSignalInstrument2ID"
              ref="transmitSignalInstrument2ID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择发射信号源2"
              style="width: 80%"
              @click.native="LoadSendChainInstrumentList"
            >
              <el-option
                v-for="item in recetransmitSignalInstrumentList"
                :key="item.ID"
                :label="item.name"
                :value="item.instrumentID"
              />
            </el-select>
            <el-button
              v-if="task.transmitSignalInstrument2ID"
              icon="el-icon-search"
              circle
              @click="parentClick(task.transmitSignalInstrument2ID)"
            ></el-button>
          </el-form-item>
        </el-col>

        <!-- 接收频谱仪1 -->
        <el-col :span="12">
          <el-form-item
            label="接收频谱仪1"
            prop="receiveSpectrumInstrument1ID"
          >
            <el-select
              ref="receiveSpectrumInstrument1ID"
              v-model="task.receiveSpectrumInstrument1ID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择接收频谱仪1"
              style="width: 80%"
              @click.native="LoadReceiveChainIDInstrumentList"
            >
              <el-option
                v-for="item in receiveSpectrumInstrument1List"
                :key="item.ID"
                :label="item.name"
                :value="item.instrumentID"
              />
            </el-select>
            <el-button
              v-if="task.receiveSpectrumInstrument1ID"
              icon="el-icon-search"
              circle
              @click="parentClick(task.receiveSpectrumInstrument1ID)"
            ></el-button>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 10 -->
      <el-row>
        <!-- 发射频谱仪 -->
        <el-col :span="12">
          <el-form-item
            label="发射频谱仪"
            prop="transmitSpectrumInstrumentID"
          >
            <el-select
              ref="transmitSpectrumInstrumentID"
              v-model="task.transmitSpectrumInstrumentID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择发射频谱仪"
              style="width: 80%"
              @click.native="LoadSendChainInstrumentList"
            >
              <el-option
                v-for="item in transmitSpectrumInstrumentList"
                :key="item.ID"
                :label="item.name"
                :value="item.instrumentID"
              />
            </el-select>
            <el-button
              v-if="task.transmitSpectrumInstrumentID"
              icon="el-icon-search"
              circle
              @click="parentClick(task.transmitSpectrumInstrumentID)"
            ></el-button>
          </el-form-item
          >
        </el-col>

        <!-- 接收频谱仪2 -->
        <el-col :span="12">
          <el-form-item
            label="接收频谱仪2"
            prop="receiveSpectrumInstrument2ID"
          >
            <el-select
              ref="receiveSpectrumInstrument2ID"
              v-model="task.receiveSpectrumInstrument2ID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择接收频谱仪2"
              style="width: 80%"
              @click.native="LoadReceiveChainIDInstrumentList"
            >
              <el-option
                v-for="item in receiveSpectrumInstrument1List"
                :key="item.ID"
                :label="item.name"
                :value="item.instrumentID"
              />
            </el-select>
            <el-button
              v-if="task.receiveSpectrumInstrument2ID"
              icon="el-icon-search"
              circle
              @click="parentClick(task.receiveSpectrumInstrument2ID)"
            ></el-button>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 11 -->
      <el-row>
        <!-- 发射功率计 -->
        <el-col :span="12">
          <el-form-item
            label="发射功率计"
            prop="transmitPowerInstrumentID"
          >
            <el-select
              ref="transmitPowerInstrumentID"
              v-model="task.transmitPowerInstrumentID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择发射功率计"
              style="width: 80%"
              @click.native="LoadSendChainInstrumentList"
            >
              <el-option
                v-for="item in transmitPowerInstrumentList"
                :key="item.ID"
                :label="item.name"
                :value="item.instrumentID"
              />
            </el-select>
            <el-button
              v-if="task.transmitPowerInstrumentID"
              icon="el-icon-search"
              circle
              @click="parentClick(task.transmitPowerInstrumentID)"
            ></el-button>
          </el-form-item>
        </el-col>

        <!-- 接收功率计 -->
        <el-col :span="12">
          <el-form-item
            label="接收功率计"
            prop="receivePowerInstrumentID"
          >
            <el-select
              ref="receivePowerInstrumentID"
              v-model="task.receivePowerInstrumentID"
              class="filter-item"
              clearable
              filterable
              placeholder="请选择接收功率计"
              style="width: 80%"
              @click.native="LoadReceiveChainIDInstrumentList"
            >
              <el-option
                v-for="item in receivePowerInstrumentList"
                :key="item.ID"
                :label="item.name"
                :value="item.instrumentID"
              />
            </el-select>
            <el-button
              v-if="task.receivePowerInstrumentID"
              icon="el-icon-search"
              circle
              @click="parentClick(task.receivePowerInstrumentID)"
            ></el-button>
          </el-form-item>
        </el-col>
      </el-row>

      <!-- 12 -->
      <el-row>
        <!-- 发射功率计通道 -->
        <el-col :span="12">
          <el-form-item
            label="发射功率计通道"
            prop="transmitPowerChannel"
          >
            <el-input-number
              v-model="task.transmitPowerChannel"
              :min="1"
              :max="4"
              label="发射功率计通道"
              style="width: 80%"
            ></el-input-number>
          </el-form-item
          >
        </el-col>

        <!-- 接收功率计通道 -->
        <el-col :span="12">
          <el-form-item
            label="接收功率计通道"
            prop="receivePowerChannel"
          >
            <el-input-number
              v-model="task.receivePowerChannel"
              :min="1"
              :max="4"
              label="接收功率计通道"
              style="width: 80%"
            ></el-input-number>
          </el-form-item>
        </el-col>
      </el-row>
    </el-form>

    <!-- 仪器面板 -->
    <InstrumentPanel ref="instrumentPanel"></InstrumentPanel>
  </div>
</template>

<script>
import {
  getChainInstrumentList,
  getChainList,
  getSentenceList,
  getStationList,
  getStationSatelliteList
} from '@/api/weixing/base'
import { isNotEmpty } from '@/utils'
import option from '@/common/weixing/option'
import { doFormula } from '@/api/weixing/sentence'
import { getToken } from '@/utils/auth'
import InstrumentPanel from '@/views/test/instrumentPanelTest/components/YQ'

const bandTypes = option.bandTypes
const polarisationTypes = option.polarisationTypes

export default {
  name: 'TaskStepThree',
  components: { InstrumentPanel },
  props: {
    satelliteID: {
      type: String,
      default: ''
    },
    task: {
      type: Object,
      default: null
    },
    taskDefine: {
      type: Object,
      default: null
    },
    form: {
      type: Object,
      default: null
    },
    sendStationList: {
      type: Object,
      default: null
    },
    receiveStationList: {
      type: Object,
      default: null
    },
    sendChainList: {
      type: Object,
      default: null
    },
    receiveChainList: {
      type: Object,
      default: null
    },
    sendReceiveChainList: {
      type: Object,
      default: null
    },
    receiveSendChainList: {
      type: Object,
      default: null
    },
    recetransmitSignalInstrumentList: {
      type: Object,
      default: null
    },
    injectSignalInstrumentList: {
      type: Object,
      default: null
    },
    receiveSpectrumInstrument1List: {
      type: Object,
      default: null
    },
    transmitSpectrumInstrumentList: {
      type: Object,
      default: null
    },
    transmitPowerInstrumentList: {
      type: Object,
      default: null
    },
    receivePowerInstrumentList: {
      type: Object,
      default: null
    }
  },
  data() {
    return {
      bandTypes,
      polarisationTypes,
      chainUpSkyLossSentence: '',
      chainDownSkyLossSentence: ''
    }
  },
  created() {
    this.init()
  },
  methods: {
    async init() {
      let response = await getSentenceList('code=chainUpSkyLoss', 'contentFormat')
      let sentence = response.body.data.rows
      if (sentence.length > 0) {
        this.chainUpSkyLossSentence = sentence[0].contentFormat
      }

      this.task.transmitPowerChannel = this.taskDefine.transmitPowerChannel
      this.task.receivePowerChannel = this.taskDefine.receivePowerChannel

      response = await getSentenceList('code=chainDownSkyLoss', 'contentFormat')
      sentence = response.body.data.rows
      if (sentence.length > 0) {
        this.chainDownSkyLossSentence = sentence[0].contentFormat
      }
      await this.countSentence(1, this.chainUpSkyLossSentence)
      await this.countSentence(2, this.chainDownSkyLossSentence)
    },
    LoadStationList() {
      getStationList('organizationID=' + this.$store.state.user.info.organizationID).then((response) => {
        this.sendStationList = response.body.data.rows
        this.receiveStationList = response.body.data.rows
      })
    },
    LoadSendChainList() {
      if (isNotEmpty(this.task.sendStationID)) {
        getChainList('workType=1,stationID=' + this.task.sendStationID).then((response) => {
          this.sendChainList = response.body.data.rows
        })
      } else {
        this.sendChainList = []
      }
    },

    // 接收链路
    LoadReceiveChainList() {
      if (isNotEmpty(this.task.receiveStationID)) {
        getChainList('workType=2,stationID=' + this.task.receiveStationID).then((response) => {
          this.receiveChainList = response.body.data.rows
        })
      } else {
        this.receiveChainList = []
      }
    },

    // 回传链路
    LoadSendReceiveChainList() {
      if (isNotEmpty(this.task.sendStationID)) {
        getChainList('workType=4,stationID=' + this.task.sendStationID).then((response) => {
          this.sendReceiveChainList = response.body.data.rows
        })
      } else {
        this.sendReceiveChainList = []
      }
    },

    // 注入链路
    LoadReceiveSendChainList() {
      if (isNotEmpty(this.task.receiveStationID)) {
        getChainList('workType=3,stationID=' + this.task.receiveStationID).then((response) => {
          this.receiveSendChainList = response.body.data.rows
        })
      } else {
        this.receiveSendChainList = []
      }
    },

    // 发射链路仪器
    LoadSendChainInstrumentList() {
      if (isNotEmpty(this.task.sendChainID)) {
        getChainInstrumentList(
          'chainID=' + this.task.sendChainID,
          'instrumentID,instrument.instrumentID.instrumentType'
        ).then((response) => {
          const chainInstrumentList = response.body.data.rows
          this.recetransmitSignalInstrumentList = chainInstrumentList.filter(
            (ele) => ele.instrument_instrumentType === 1
          )
          this.transmitSpectrumInstrumentList = chainInstrumentList.filter(
            (ele) => ele.instrument_instrumentType === 3
          )
          this.transmitPowerInstrumentList = chainInstrumentList.filter(
            (ele) => ele.instrument_instrumentType === 5
          )
        })
      }
    },

    // 接收链路仪器
    LoadReceiveChainIDInstrumentList() {
      if (isNotEmpty(this.task.receiveChainID)) {
        getChainInstrumentList(
          'chainID=' + this.task.receiveChainID,
          'instrumentID,instrument.instrumentID.instrumentType'
        ).then((response) => {
          const chainInstrumentList = response.body.data.rows
          this.receiveSpectrumInstrument1List = chainInstrumentList.filter(
            (ele) => ele.instrument_instrumentType === 3
          )
          this.receivePowerInstrumentList = chainInstrumentList.filter(
            (ele) => ele.instrument_instrumentType === 5
          )
        })
      }
    },

    // 注入链路仪器
    LoadReceiveSendChainInstrumentList() {
      if (isNotEmpty(this.task.receiveSendChainID)) {
        getChainInstrumentList(
          'chainID=' + this.task.receiveSendChainID,
          'instrumentID,instrument.instrumentID.instrumentType'
        ).then((response) => {
          const chainInstrumentList = response.body.data.rows
          this.injectSignalInstrumentList = chainInstrumentList.filter(
            (ele) => ele.instrument_instrumentType === 1
          )
        })
      }
    },
    parentClick(id) {
      this.$refs.instrumentPanel.mmp(id) // 调用子组件的方法childClick
      console.log(id)
    },
    async countSentence(type, contentFormat) {
      const h = this.$createElement
      let stationSatelliteID
      let stationID
      let msg

      switch (type) {
        case 1: // 上行
          msg = '发射'
          stationID = this.task.sendStationID
          break
        case 2: // 下行
          msg = '接收'
          stationID = this.task.receiveStationID
          break
      }
      if (!isNotEmpty(stationID)) {
        this.$msgbox({
          title: '错误',
          type: 'error',
          closeOnClickModal: false, // 点击区域外不可关闭
          closeOnPressEscape: false, // 按ESC不可关闭
          message: h('p', null, [
            h('i', { style: 'color: red' }, msg + '地面站'),
            h('span', null, ' 不能为空 ')
          ])
        })
      } else if (!isNotEmpty(this.task.transponderID)) {
        this.$msgbox({
          title: '错误',
          type: 'error',
          closeOnClickModal: false, // 点击区域外不可关闭
          closeOnPressEscape: false, // 按ESC不可关闭
          message: h('p', null, [
            h('i', { style: 'color: red' }, '卫星转发器'),
            h('span', null, ' 不能为空 ')
          ])
        })
      } else {
        const { header, body } = await getStationSatelliteList(
          'stationID=' + stationID + ',satelliteID=' + this.satelliteID
        )
        if (header.code !== 0) {
          this.$msgbox({
            title: '错误',
            type: 'error',
            closeOnClickModal: false, // 点击区域外不可关闭
            closeOnPressEscape: false, // 按ESC不可关闭
            message: h('p', null, [
              h('span', null, '获取 '),
              h('i', { style: 'color: red' }, '星地距离'),
              h('span', null, ' 失败 ')
            ])
          })
        } else {
          if (body.data.rows.length > 0) {
            stationSatelliteID = body.data.rows[0].ID
            const res = await doFormula({
              token: getToken(),
              mathematicalFormula: contentFormat,
              parameterIDArray: 'stationSatelliteID=' + stationSatelliteID + ',transponderID=' + this.task.transponderID
            })
            switch (type) {
              case 1:
                this.task.chainUpSkyLoss = res.body.calculationResult.toFixed(2)
                break
              case 2:
                this.task.chainDownSkyLoss = res.body.calculationResult.toFixed(2)
                break
            }
          } else {
            this.$msgbox({
              title: '错误',
              type: 'error',
              closeOnClickModal: false, // 点击区域外不可关闭
              closeOnPressEscape: false, // 按ESC不可关闭
              message: h('p', null, [
                h('i', { style: 'color: red' }, '地面站'),
                h('span', null, ' 与 '),
                h('i', { style: 'color: red' }, '卫星'),
                h('span', null, ' 未进行关联')
              ])
            })
          }
        }
      }
    },
    isNotEmpty: isNotEmpty
  }
}
</script>

<style scoped>

</style>
